// File:       poscmd05.c++
// Version:    1.00
// Author:     (c) Miles Sabin, 1997
// Purpose:    write command

// Change log:
//  29/03/97   v. 1.00

#include "poscmds.h"

#include "ostream.h"
#include "streambuf.h"


// Implementation of WriteCommand

WriteCommand::WriteCommand(basic_ostream_char& os, char const* s, streamsize n)
  : s_(s),
    n_(n)
  { execute_template(os); }

WriteCommand::~WriteCommand()
  {}

ios::iostate WriteCommand::execute(basic_ostream_char& os)
  { return (os.rdbuf()->sputn(s_, n_) != n_ ? ios::badbit : ios::goodbit); }


// Implementation of basic_ostream_char

basic_ostream_char& basic_ostream_char::write(char const* s, streamsize n)
  {
    WriteCommand cmd(*this, s, n);
    return *this;
  }

